import React, {Component} from "react"
import UserInfo from "./userInfo"
import Login from "../../container/mine/login/index"
import Regist from "./regist"

class Mine extends Component{
    constructor(){
        super()
        this.state={
            isLogin:false,
            type:3,
            username:"",
            password:""
        }
    }
    changeType(type,username,password){
        this.setState({
            type:type,
            username:username,
            password:password
        })
        console.log(type,username,password)
    }
    render(){
        let temp;
        if(this.state.isLogin){
            temp=<Login/>
        }else{
            switch(this.state.type){
                case 1:
                temp=<UserInfo username={this.state.username}/>;
                break;
                case 2:
                temp=<Login username={this.state.username} password={this.state.password} changeType={this.changeType.bind(this)} />;
                break;
                case 3:
                temp=<Regist changeType={this.changeType.bind(this)} type={this.state.type}/>;
                break;
            }
        }
        return(
            <div>
               {temp}
            </div>
        )
    }
}
export default Mine